package operation;

import book.Book;
import book.BookList;
import book.ListNode;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mac
 * Date: 2022-09-08
 * Time: 11:03
 */
public class AddOperation implements IOperation{
    public void work(BookList bookList) {
        System.out.println("新增图书");
        System.out.println("请输入书名");
        String bookname = scanner.nextLine();
        System.out.println("请输入作者");
        String bookauthor = scanner.nextLine();
        System.out.println("请输入类型");
        String booktype = scanner.nextLine();
        System.out.println("请输入定价");
        int bookprice = scanner.nextInt();
        Book book = new Book(bookname, bookauthor, bookprice, booktype);

        ListNode newHead = bookList.getHead();
        ListNode node = new ListNode(book);
        node.next = newHead;
        bookList.setHead(node);
        System.out.println("新增成功！");
    }
}
